package com.wang.sqlsession;

import com.wang.config.XMLConfigBuilder;
import com.wang.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

/**
 * Created by wangq on 2021/6/29.
 */
public class SqlSessionFactoryBuilder {

    public static SqlSessionFactory build(InputStream inputStream) throws Exception {
        // 1.使用dom4j解析配置文件 将解析内容封装到Configuration中
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);

        // 2.创建sessionFactory工厂对象，用于生成sqlSession
        return new DefaultSqlSessionFactory(configuration);
    }
}
